<template>
  <div class="headers">
    <div class="header_one">{{ $t("notice.notice") }}</div>
    <div class="table_text">
      <el-table :data="tableDataCurrent" border style="width: 100%">
        <el-table-column label="NO" type="index" align="center" width="80">
          <template slot-scope="scope">
            {{ (query.page - 1) * 10 + scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column prop="title" label="Subject" align="center">
        </el-table-column>
        <el-table-column prop="content" label="Attachments" align="center">
          <template slot-scope="scope">
            <span
              style="color: skyblue"
              class="cursor"
              @click="btnFn(scope.row)"
            >
              {{ scope.row.content }}</span
            >
          </template>
        </el-table-column>
        <el-table-column prop="date" label="Date Created" align="center">
        </el-table-column>
        <el-table-column prop="count" label="views" align="center">
        </el-table-column>
      </el-table>
      <el-pagination
        style="text-align: center; margin: 20px 0"
        background
        v-show="tableData.total > 0"
        :total="tableData.total"
        :page.sync="listQuery.page"
        :page-size="listQuery.limit"
        :size.sync="listQuery.limit"
        @current-change="getLists"
        layout="total,prev, pager, next"
      >
      </el-pagination>
      <el-dialog
        title=""
        :visible.sync="dialogVisible"
        width="90%"
        :before-close="handleClose"
        :close-on-click-modal="false"
      >
        <div class="header_ones" style="margin-top: 10px">
          {{ cont }}
        </div>
        <div class="dialog_text2" v-html="htmls"></div>
      </el-dialog>
    </div>
  </div>
</template>
<script>
import { index, detail } from "@/api/omc.js"; // 资料列表
export default {
  data() {
    return {
      dialogVisible: false, // 弹窗
      query: {
        page: 1, // 当前页
        row: 10, // 每页条数
      },
      querys: {
        id: "",
      },
      cont: "",
      listQuery: {
        // Dang当前页
        page: 1,
        // 每页多少条
        limit: 6,
      },
      htmls: "", // 返回的数据结构
      tableData: {},
      tableDataCurrent: [],
    };
  },
  created() {
    this.index();
  },
  methods: {
    // 点击跳转到详情页
    btnFn(row) {
      console.log(row);
      this.querys.id = row.id;
      this.detail(this.querys);
      this.cont = row.content;
      this.dialogVisible = true;
    },
    // 分页
    getLists(val) {
      console.log(val);
      this.loadings = true;
      this.tableDataCurrent = this.tableData.data.slice(
        (val - 1) * this.listQuery.limit,
        val * this.listQuery.limit
      );
      console.log((this.listQuery.page - 1) * this.listQuery.limit);
      console.log(this.listQuery.page * this.listQuery.limit);
      this.loadings = false;
      console.log(this.tableDataCurrent);
    },
    // 详情接口
    async detail(query) {
      try {
        const data = await detail(query);
        console.log(data);
        this.htmls = data.data.detail;
      } catch (error) {
        console.log(error);
      }
    },
    // 重置接口
    async index(query) {
      try {
        const data = await index(query);
        this.tableData = data.data;
        console.log(data);
        this.getLists(1);
      } catch (error) {
        console.log(error);
      }
    },
    handleClose() {
      this.dialogVisible = false;
      this.index();
    },
  },
};
</script>

<style scoped>
::v-deep .el-pagination span:not([class*="suffix"]) {
  font-size: 22px;
  line-height: 44px;
}
::v-deep .btn-prev {
  text-align: center;
  line-height: 33px;
  width: 44px !important;
  height: 44px !important;
}
::v-deep .btn-next {
  text-align: center;
  line-height: 33px;
  width: 44px !important;
  height: 44px !important;
}
::v-deep .el-pager li {
  font-size: 20px;
  text-align: center;
  line-height: 44px;
  width: 44px !important;
  height: 44px !important;
}
.dialog_text1 {
  margin: 22px 0 0 145px;
  width: 1622px;
  font-size: 28px;
  font-family: Arial;
  font-weight: 400;
  color: #666666;
  line-height: 48px;
}
.dialog_text2 img {
  width: 80%;
  height: 400px;
}
.dialog_text2 {
  font-size: 30px;
}
.el-table {
  font-size: 20px;
}
::v-deep .el-table .el-table__cell {
  padding: 20px 0 !important;
}
.headers {
  background: #ffffff;
  height: 720px;
}
.header_one {
  margin: 65px 0 0 143px;
  width: 691px;
  font-size: 56px;
  font-family: Arial;
  font-weight: bold;
  color: #666666;
  line-height: 110px;
}
.header_ones {
  font-size: 30px;
  font-family: Arial;
  font-weight: bold;
  color: #666666;
}
.table_text {
  margin: 75px 142px 0;
}
</style>